//
//  ViewController.m
//  ViewController
//
//  Created by student on 16/2/20.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
//左边的文本框
@property (weak, nonatomic) IBOutlet UITextField *leftField;
//右边的文本框
@property (weak, nonatomic) IBOutlet UITextField *rightField;
//结果文本框
@property (weak, nonatomic) IBOutlet UILabel *sumLabel;




@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)doSum
{
    //获取左边文本框输入的文字，转为数字
    int num1 = [self.leftField.text intValue];
    //获取右边文本框输入的文字，转为数字
    int num2 = [self.rightField.text intValue];
    //计算结果
    int sum = num1 + num2;
    //修改显示内容
    self.sumLabel.text = [NSString stringWithFormat:@"%d",sum];
    //收起键盘
    [self.view endEditing:YES];
}








@end
